bitkeeper revision 1.1659 (42a010dfU0RKWV-1WrueKEs8brwyOg)
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 3 Jun 2005 08:12:15 +0000 (08:12 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 3 Jun 2005 08:12:15 +0000 (08:12 +0000)
Ensure that _PAGE_GLOBAL bit is never set in any pagetable if the CPU
does not support PGE (Page Global Extension).
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/setup.c
xen/arch/x86/x86_32/mm.c
xen/include/asm-x86/page.h
xen/include/asm-x86/x86_32/page.h
xen/include/asm-x86/x86_64/page.h

index 599389aaadbcf23ad05a91c7d87f68f42c1edcc1..c0db9f9c7db251501e5e183b9595aff99a25fd6c 100644 (file)
@@ -147,6 +147,8 @@ static void __init start_of_day(void)
 
     early_cpu_init();
 
+    paging_init();
+
     /* Unmap the first page of CPU0's stack. */
     memguard_guard_stack(cpu0_stack);
 
@@ -168,8 +170,6 @@ static void __init start_of_day(void)
 
     smp_alloc_memory();
 
-    paging_init();
-
     dmi_scan_machine();
 
     generic_apic_probe();
index 89537fe7af569ce9a176273fd85370991f01c4d8..99dd178feabcf21dba349827808d894c5934cb5c 100644 (file)
@@ -28,6 +28,9 @@
 #include <asm/fixmap.h>
 #include <asm/domain_page.h>
 
+unsigned int PAGE_HYPERVISOR         = __PAGE_HYPERVISOR;
+unsigned int PAGE_HYPERVISOR_NOCACHE = __PAGE_HYPERVISOR_NOCACHE;
+
 static unsigned long mpt_size;
 
 struct pfn_info *alloc_xen_pagetable(void)
@@ -72,6 +75,19 @@ void __init paging_init(void)
 
     idle0_vcpu.arch.monitor_table = mk_pagetable(__pa(idle_pg_table));
 
+    if ( cpu_has_pge )
+    {
+        /* Suitable Xen mapping can be GLOBAL. */
+        PAGE_HYPERVISOR         |= _PAGE_GLOBAL;
+        PAGE_HYPERVISOR_NOCACHE |= _PAGE_GLOBAL;
+        /* Transform early mappings (e.g., the frametable). */
+        for ( v = HYPERVISOR_VIRT_START; v; v += (1 << L2_PAGETABLE_SHIFT) )
+            if ( (l2e_get_flags(idle_pg_table_l2[l2_linear_offset(v)]) &
+                  (_PAGE_PSE|_PAGE_PRESENT)) == (_PAGE_PSE|_PAGE_PRESENT) )
+                l2e_add_flags(idle_pg_table_l2[l2_linear_offset(v)],
+                              _PAGE_GLOBAL);
+    }
+
     /*
      * Allocate and map the machine-to-phys table and create read-only mapping 
      * of MPT for guest-OS use.  Without PAE we'll end up with one 4MB page, 
@@ -86,26 +102,12 @@ void __init paging_init(void)
         if ( (pg = alloc_domheap_pages(NULL, PAGETABLE_ORDER)) == NULL )
             panic("Not enough memory to bootstrap Xen.\n");
         idle_pg_table_l2[l2_linear_offset(RDWR_MPT_VIRT_START) + i] =
-            l2e_from_page(pg, __PAGE_HYPERVISOR | _PAGE_PSE);
+            l2e_from_page(pg, PAGE_HYPERVISOR | _PAGE_PSE);
         idle_pg_table_l2[l2_linear_offset(RO_MPT_VIRT_START) + i] =
             l2e_from_page(pg, (__PAGE_HYPERVISOR | _PAGE_PSE) & ~_PAGE_RW);
     }
     memset((void *)RDWR_MPT_VIRT_START, 0x55, mpt_size);
 
-    /* Xen PSE mappings can all be GLOBAL. */
-    if ( cpu_has_pge )
-    {
-        for ( v = HYPERVISOR_VIRT_START; v; v += (1 << L2_PAGETABLE_SHIFT) )
-        {
-            if ( (l2e_get_flags(idle_pg_table_l2[l2_linear_offset(v)]) &
-                  (_PAGE_PSE|_PAGE_PRESENT)) != (_PAGE_PSE|_PAGE_PRESENT) )
-                continue;
-            if ( (v >= RO_MPT_VIRT_START) && (v < RO_MPT_VIRT_END) )
-                continue;
-            l2e_add_flags(idle_pg_table_l2[l2_linear_offset(v)], _PAGE_GLOBAL);
-        }
-    }
-
     /* Create page tables for ioremap(). */
     for ( i = 0; i < (IOREMAP_MBYTES >> (L2_PAGETABLE_SHIFT - 20)); i++ )
     {
index 126f3591ab39933388800c0890525e4daa69b318..536cb63275cb78d9285d89e3f2c67bfc8f47c559 100644 (file)
@@ -257,11 +257,6 @@ extern void paging_init(void);
 #define __PAGE_HYPERVISOR_NOCACHE \
     (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_PCD | _PAGE_ACCESSED)
 
-#define MAKE_GLOBAL(_x) ((_x) | _PAGE_GLOBAL)
-
-#define PAGE_HYPERVISOR MAKE_GLOBAL(__PAGE_HYPERVISOR)
-#define PAGE_HYPERVISOR_NOCACHE MAKE_GLOBAL(__PAGE_HYPERVISOR_NOCACHE)
-
 #ifndef __ASSEMBLY__
 
 static __inline__ int get_order(unsigned long size)
index 988da658110956d1b59cce3f7c64c61d06b4d851..9546706876260818b96af5de6b8a0a509c5038f1 100644 (file)
 #define l1_linear_offset(_a) ((_a) >> L1_PAGETABLE_SHIFT)
 #define l2_linear_offset(_a) ((_a) >> L2_PAGETABLE_SHIFT)
 
+#ifndef __ASSEMBLY__
+extern unsigned int PAGE_HYPERVISOR;
+extern unsigned int PAGE_HYPERVISOR_NOCACHE;
+#endif
+
 #endif /* __X86_32_PAGE_H__ */
 
 /*
index 21712d19d98ac967247c15d638adda56b7e64256..eeafe4fea55bd4db3afc7fef02c5e73bae66ae40 100644 (file)
@@ -76,6 +76,9 @@ typedef l4_pgentry_t root_pgentry_t;
 #define L3_DISALLOW_MASK (0xFFFFF180U & ~_PAGE_NX) /* must-be-zero */
 #define L4_DISALLOW_MASK (0xFFFFF180U & ~_PAGE_NX) /* must-be-zero */
 
+#define PAGE_HYPERVISOR         (__PAGE_HYPERVISOR         | _PAGE_GLOBAL)
+#define PAGE_HYPERVISOR_NOCACHE (__PAGE_HYPERVISOR_NOCACHE | _PAGE_GLOBAL)
+
 #endif /* __X86_64_PAGE_H__ */
 
 /*